<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ taglib prefix ="s" uri="/struts-tags"%>
<!DOCTYPE html>

<html lang="en">
<head>
<%@ include file="/common/common-css.jsp"%>
</head>
<body class="no-skin">

<form name="queryForm" style="min-height:350px;">
<br/>
时间:
<input id="costtime" type="text" name="time" data-date-format="yyyy/mm/dd" class="date-picker">
<br/>
数量:
<input id="costnum" type="text" name="带量"/>
<br/>
违章:
<input id="wznum" type="text" name="带量"/>
<br/>
渠道:
<select name="channelId" id="channel-id">
						
</select>

<br>
<br>

<button class="btn  btn-success no-border" name="btn-save" id="btn-save">
		<i class="ace-icon fa fa-floppy-o bigger-160"></i> 确认
</button>

</form>
<%@ include file="/common/common-js.jsp" %>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
<script>      
		
		function getQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
 			var r = window.location.search.substr(1).match(reg);
			if (r != null) return decodeURI(r[2]); return null;
	 	};
		jQuery(function() {
			//时间控件
			$(".date-picker").datetimepicker({
				autoclose:true,
				minView: "month",
		    });
			
			$.ajax({
				"type": "POST",
				"dataType": 'json',
				"url": ctx+"/spread/channelListRequest.action?getChildrenList=1&status=1",
				"success": function(resp){
					console.log(resp);
					var option = '';
					$.each(resp.aaData, function(index,item){
						option += '<option value='+item.id+'>'+item.channel+'</option>';
					});	
					$('#channel-id').html(option);
					channelId = $('#channel-id').val();;		
				},
				"error": function(XMLHttpRequest, textStatus, errorThrown) {
					alert(textStatus);
				}
			});
			
			
			$("#btn-save").bind("click",function() {
				
				$("#btn-save").attr("disabled","disabled");
				if($("#coustnum").text() == null){
					$("#btn-save").removeAttr("disabled");
					return;
				}
				var channel = $("#channel-id").val();
				var cost = $("#costnum").val();
				var wznum = $("#wznum").val();
				var costtime = $("#costtime").val();
				
				$("#btn-save").attr("disabled","disabled");
				$.ajax({
					 url: ctx + "/spread/addRecordRequest.action?channel="+channel+"&cost="+cost+"&costtime="+costtime+"&wznum="+wznum,
					 dataType:"json",
					 success: function(data){							 
						if(data.result.status != 1){
							alert(data.result.msg);
						}else{
							parent.parent['__extdialog_active'].dialog('close');
							parent.main_frame.query_any();	
						}
					},
					error: function(a,b,c){
						alert(b);
					}
			   });
			   return false;
			});
	    });
	</script>
</body>
</html>